$(function () {
    useLayUI();
    $(document).on('click', '.edit-btn', function() {
        var pop_div = $(this).data('pop');
        popupDiv(pop_div);
    });
    $(".detail-list .add-btn").click(function () {
        var pop_div = $(this).data('pop');
        popupDiv(pop_div);
    });
});

//个人简历
var resume = new Vue({
    el: "#personal_center",
    data() {
        return {
            services:services,
            userInfo:'',
            sexImg:'',
            age:null,
            workAge:null,
            careerObjective:[],
            experienceWork:null,
            experienceEducation:[],
            professionalSkill:null,
            experienceProject:null,
            resume:'',
            birthYear:'',
            firstWorkTime:'',
            resumeId:'',
            deliveryAll:0,
            handlepending:0,
            interviewpending:0,
            unsuited:0,
            accepted:0,
            telFlag:true,
            emailFlag:true,
            wechatFlag:true,
            websiteFlag:true
        }
    },
    created () {
        this.userInfo = LoginStatus();
        if(this.userInfo==false)
            return false;
        //判断性别，显示性别图标
        var sex = this.userInfo.gender;
        if(sex==1){
            this.sexImg = '../images/male.png';
        }else if(sex==2){
            this.sexImg = '../images/female.png';
        }else {
            this.sexImg = null;
        }
        //联系方式如果是空的就不显示
        if(!this.userInfo.tel){
            this.telFlag = false;
        }
        if(!this.userInfo.email){
            this.emailFlag = false;
        }
        if(!this.userInfo.wechat){
            this.wechatFlag = false;
        }
        if(!this.userInfo.webSite){
            this.websiteFlag = false;
        }
        //获取岁数，工作时间
        var thisYear =  parseInt(new Date().getFullYear());
        this.birthYear = parseInt(this.userInfo.birthday.substring(0,4));
        if(this.userInfo.firstWorkTime!=null){
            this.firstWorkTime = parseInt(this.userInfo.firstWorkTime.substring(0,4));
        }
        this.age = thisYear-this.birthYear;
        if(this.firstWorkTime){
            this.workAge = thisYear-this.firstWorkTime;
        }else{
            this.workAge = 0;
        }
        
        this.init();
        //全部
        this.deliveryAll =  this.delivery("/user/resume/delivery/list?page=1&limit=2000&status=&companyFullName=&positionName=&userName=")
        //已查看
        this.handlepending = this.delivery("/user/resume/delivery/list?page=1&limit=2000&status=1&companyFullName=&positionName=&userName=")
        //待面试
        this.interviewpending = this.delivery("/user/resume/delivery/list?page=1&limit=2000&status=2&companyFullName=&positionName=&userName=")
        //不适合
        this.unsuited = this.delivery("/user/resume/delivery/list?page=1&limit=2000&status=4&companyFullName=&positionName=&userName=")
        //已录取
        this.accepted = this.delivery("/user/resume/delivery/list?page=1&limit=2000&status=3&companyFullName=&positionName=&userName=")

    },
    methods:{
        init:function () {
            var that=this;
            $.ajax({
                url:that.services+"/user/resume"
                ,type:"get"
                ,async:false
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,success:function(res){
                    var check = ApiLoginStatus(res);
                        if(check==false)
                            return false;
                    if(res.success){
                        that.careerObjective = res.data.careerObjective[0];
                        that.experienceWork = res.data.experienceWork;
                        that.experienceEducation = res.data.experienceEducation[0];
                        that.professionalSkill = res.data.professionalSkill;
                        that.experienceProject = res.data.experienceProject;
                        that.resume = res.data.resume;
                        that.resumeId = that.experienceEducation.resumeId;
                        $.cookie('resumeId', that.resumeId);
                        if(!window.localStorage){
                            return false;
                        }else{
                            //存localstorage
                            var storage=window.localStorage;
                            storage.my_intro=that.resume.profile;
                            storage.projects=JSON.stringify(that.experienceProject);
                            storage.skills=JSON.stringify(that.professionalSkill);
                            storage.education=JSON.stringify(that.experienceEducation);
                            storage.jobs=JSON.stringify(that.experienceWork);
                        }

                    }else {
                        layerMsg(res.message);
                        setTimeout(function () {
                            window.location.href="register-work.html" ;
                        }, 1500);
                    }
                }
            });

        },
        //投递记录
        delivery:function(_url){
            var that=this;
            var count = 0;
            $.ajax({
                url:that.services+_url
                ,type:"get"
                ,async:false
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,success:function(res){
                    var obj = JSON.parse(res)
                    count = obj.count;
                }
            });
            return count;
        }
    }
});

//个人信息
new Vue({
    el: "#pop_info",
    data() {
        return {
            services: services,
            userInfo:'',
            sexCheck:true,
            sex:null,
        }
    },
    created () {
        this.userInfo = LoginStatus();
        if(this.userInfo==false)
            return false;
        //判断性别
        if(this.userInfo.gender==1){
            this.sexCheck=true;
        }else if(this.userInfo.gender==2){
            this.sexCheck=false;
        }
    },
    methods:{
        alterInfo(){
            var that = this;
            if(that.userInfo.name==''||that.userInfo.name==null){
                layerMsg("名字不可以为空");
                return
            }
            if(!(/^1[34578]\d{9}$/.test(that.userInfo.tel))){
                layerMsg("请输入正确的手机号码格式");
                return
            }
            if(!(/^\w+@[a-z0-9]+\.[a-z]+$/i.test(that.userInfo.email))){
                layerMsg("请输入正确的邮箱格式");
                return
            }
            that.sex =  $('input[name="sex"]:checked').val();
            that.userInfo.img = $('input[name="img"]').val();
           
            if(that.sex==1){
                resume.sexImg = '../images/male.png';
            }else if(that.sex==2){
                resume.sexImg = '../images/female.png';
            }else {
                resume.sexImg = null;
            }
            that.userInfo.birthday = $('input[name="borth"]').val();
            that.userInfo.firstWorkTime = $('input[name="start"]').val();

            $.ajax({
                url:that.services+"/user/info"
                ,type:"post"
                ,contentType:"application/json;charset=utf-8"
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,data:JSON.stringify({
                    "name": that.userInfo.name,
                    "gender": that.sex,
                    "img":that.userInfo.img,
                    "birthday": that.userInfo.birthday,
                    "firstWorkTime": that.userInfo.firstWorkTime,
                    "email": that.userInfo.email,
                    "wechat": that.userInfo.wechat,
                    "webSite": that.userInfo.webSite,
                })
                ,success:function(res){
                    console.log(res);
                    if(res.success){
                        var check = ApiLoginStatus(res);
                        if(check==false)
                            return false;
                        var newUserInfo = JSON.stringify(res.data);
                        $.cookie('userInfo', newUserInfo);
                        that.userInfo = res.data;
                        resume.userInfo = res.data;
                        //获取岁数，工作时间
                        var thisYear =  parseInt(new Date().getFullYear());
                        resume.birthYear = parseInt(res.data.birthday.substring(0,4));
                        if(res.data.firstWorkTime){
                            resume.firstWorkTime = parseInt(res.data.firstWorkTime.substring(0,4));
                            resume.workAge = thisYear-resume.firstWorkTime;
                        }
                        resume.age = thisYear-resume.birthYear;
                        layerMsg(res.message);
                        setTimeout(function() {
                            // layer.closeAll();
                            history.go(0);
                        },500);
                    }else{
                        layerMsg(res.message);
                        return false
                    }
                }
            });
        }
    }
});

// 求职意向
new Vue({
    el: "#pop_intent",
    data() {
        return {
            services: services,
            intent:'',
        }
    },
    created () {
        this.intent = resume.careerObjective;
    },
    methods:{
        // init:function (_type,_url) {
        //     var that=this;
        //     var obj = "";
        //     $.ajax({
        //         type: _type,
        //         async:false,
        //         url: that.services+_url,
        //         xhrFields: {
        //             withCredentials: true
        //         },
        //         crossDomain: true,
        //         success: function (res) {
        //             var check = ApiLoginStatus(res);
        //             if(check==false)
        //                 return false;
        //             obj = (JSON.parse(res)).data;
        //         }
        //     });
        //     return obj;
        // },
        saveIntent:function () {
            var that = this;
            var formSelects = layui.formSelects;
            var careerObjectives = [];
            var jobHuntingStatus = $("select[name='jobHuntingStatus']").val();
            if(jobHuntingStatus==null||jobHuntingStatus==""){
                layerMsg("求职状态不为空");
                return false;
            }
            // var expectPosition = formSelects.value('expectPosition', 'valStr');
            var expectPosition=$("input[name='expectPosition']").val()
            if(expectPosition==null||expectPosition==""){
                layerMsg("期望职位不为空");
                return false;
            }
            var expectIndustry = formSelects.value('expectIndustry', 'valStr');
            if(expectIndustry==null||expectIndustry==""){
                layerMsg("期望行业不为空");
                return false;
            }
            var expectIndustry = formSelects.value('expectIndustry', 'valStr');
            var expectCity=$("input[name='expectCity']").val();
            if(expectCity==null||expectCity==""){
                layerMsg("期望城市不为空");
                return false;
            }
            var expectSalaryLevel=$("select[name='expectSalaryLevel']").val()
            if(expectSalaryLevel==null||expectSalaryLevel==""){
                layerMsg("期望薪酬不为空");
                return false;
            }
            var jsondata = {
                "id":that.intent.id,
                "resumeId":that.intent.resumeId,
                "jobHuntingStatus":jobHuntingStatus,
                'expectPosition':expectPosition,
                'expectIndustry':expectIndustry,
                "expectCity":expectCity,
                "expectSalaryLevel":expectSalaryLevel
            };
            careerObjectives.push(jsondata);
            $.ajax({
                url:that.services+"/user/resume/careerObjective"
                ,type:"post"
                ,contentType:"application/json;charset=utf-8"
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,data:JSON.stringify(careerObjectives[0])
                ,success:function(res){
                    var check = ApiLoginStatus(res);
                    if(check==false)
                        return false;
                    if(res.success){
                        layerMsg(res.message);
                        setTimeout(function() {
                            history.go(0);
                            layer.closeAll();
                        },500);
                    }

                }
            });
        }
    }
});

//工作经历
new Vue({
    el: "#pop_exper",
    data() {
        return {
            services: services,
            currWorkCom:'',
            currWorkStartTime:'',
            currWorkEndTime:'',
            currWorkDepart:'',
            currWorkPosition:'',
            currWorkDuty:'',
            currIndex:'',
            currId:'',
            currResumeId:'',
        }
    },
    created () {
        this.getinfo();
        this.currResumeId = resume.resumeId;
    },
    methods:{
        getinfo:function () {
            var that = this;
            $(document).on('click', '.edit-work', function() {
                var index =  $(this).data('index');
                that.currId =  $(this).data('id');
                if(index!=undefined){
                    that.currIndex = index;
                    that.currWorkCom=resume.experienceWork[that.currIndex].company;
                    that.currWorkStartTime=resume.experienceWork[that.currIndex].entryTime;
                    that.currWorkEndTime=resume.experienceWork[that.currIndex].separationTime;
                    that.currWorkDepart=resume.experienceWork[that.currIndex].department;
                    that.currWorkPosition=resume.experienceWork[that.currIndex].position;
                    that.currWorkDuty=resume.experienceWork[that.currIndex].workContext;
                }
            })
        },
        alterWork:function () {
            this.currWorkStartTime = $('input[name="alter_start"]').val();
            this.currWorkEndTime = $('input[name="alter_end"]').val();
            if(this.currWorkCom==''||this.currWorkCom==null){
                layerMsg("公司名字不可以为空");
                return
            }
            if(this.currWorkStartTime == ''||this.currWorkStartTime==null){
                layerMsg('开始工作时间不为空');
                return
            }
            if(this.currWorkEndTime == ''||this.currWorkEndTime==null){
                layerMsg('结束工作时间不为空');
                return
            }
            var that = this;
            $.ajax({
                url:that.services+"/user/resume/experienceWork"
                ,type:"post"
                ,contentType:"application/json;charset=utf-8"
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,data:JSON.stringify({
                    "id": that.currId
                    ,"resumeId": that.currResumeId
                    ,"company": that.currWorkCom
                    ,"department": that.currWorkDepart
                    ,"position": that.currWorkPosition
                    ,"entryTime": that.currWorkStartTime
                    ,"separationTime": that.currWorkEndTime
                    ,"workContext": that.currWorkDuty
                })
                ,success:function(res){
                    if(res.success){
                        var check = ApiLoginStatus(res);
                        if(check==false)
                            return false;
                        layerMsg(res.message);
                        setTimeout(function() {
                            history.go(0);
                            layer.closeAll();
                        },500);
                    }
                }
            });
        },
        deleteExperWork:function () {
            var that = this;
            $.ajax({
                url:that.services+"/user/resume/experienceWork/"+that.currId
                ,type:"delete"
                ,contentType:"application/json;charset=utf-8"
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,success:function(res){
                    if(res.success){
                        var check = ApiLoginStatus(res);
                        if(check==false)
                            return false;
                        layerMsg(res.message);
                        setTimeout(function() {
                            history.go(0);
                            layer.closeAll();
                        },500);
                    }

                }
            });
        }
    }
});
//添加工作经验
new Vue({
    el: "#add_pop_exper",
    data() {
        return {
            services: services,
            addCom:'',
            addStartTime:'',
            addEndTime:'',
            addDepart:'',
            addPosition:'',
            addDuty:'',
            ResumeId:''
        }
    },
    methods:{
        addWork:function () {
            this.addStartTime = $('input[name="add_start"]').val();
            this.addEndTime = $('input[name="add_end"]').val();

            if(this.addCom == ''||this.addCom==null){
                layerMsg('请输入公司名称');
                return
            }
            if(this.addStartTime == ''||this.addStartTime==null){
                layerMsg('请输入开始工作时间');
                return
            }
            if(this.addEndTime == ''||this.addEndTime==null){
                layerMsg('请输入结束工作时间');
                return
            }

            var that = this;
            $.ajax({
                url:that.services+"/user/resume/experienceWork"
                ,type:"put"
                ,contentType:"application/json;charset=utf-8"
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,data:JSON.stringify({
                        "resumeId": that.ResumeId,
                        "company": that.addCom,
                        "department": that.addDepart,
                        "position": that.addPosition,
                        "entryTime": that.addStartTime,
                        "separationTime": that.addEndTime,
                        "workContext": that.addDuty
                })
                ,success:function(res) {
                    if(res.success){
                        var check = ApiLoginStatus(res);
                        if(check==false)
                            return false;
                        layerMsg(res.message);
                        setTimeout(function() {
                            history.go(0);
                            layer.closeAll();
                        },500);
                    }
                }
            })
        }
    },
    created () {
        this.ResumeId = resume.resumeId;
    }
});

//教育经历
new Vue({
    el: "#pop_education",
    data() {
        return {
            services: services,
            education:'',
            school:'',
            enterTime:'',
            leaveTime:'',
            major:'',
            currInfo:'',
            currEducation:'',
            currEducationId:'',
            resumeId:'',
            teachId:''
        }
    },
    created () {
        this.education = this.init("get","/user/prop/educationLevel/list?page=0&limit=10&name=");
        this.currInfo = resume.experienceEducation;
        this.school = this.currInfo.school;
        this.enterTime = this.currInfo.admissionTime;
        this.leaveTime = this.currInfo.graduationTime;
        this.major = this.currInfo.profession;
        this.currEducation = this.currInfo.educationLevelName;
        this.currEducationId = this.currInfo.educationLevel;
        this.resumeId = this.currInfo.resumeId;
        this.teachId = this.currInfo.id;
    },
    methods:{
        init:function (_type,_url) {
            var that=this;
            var obj = "";
            $.ajax({
                type: _type,
                async:false,
                url: that.services+_url,
                xhrFields: {
                    withCredentials: true
                },
                crossDomain: true,
                success: function (res) {
                    obj = (JSON.parse(res)).data;
                }
            });
            return obj;
        },
        alterEducation:function () {

            this.currEducationId = $("#eduList").val();
            this.enterTime = $('input[name="enterTime"]').val();
            this.leaveTime = $('input[name="leaveTime"]').val();

            if(this.school==''||this.school==null){
                layerMsg("学校名字不为空");
                return
            }
            if(this.enterTime == ''||this.enterTime==null){
                layerMsg('入学时间不为空');
                return
            }
            if(this.leaveTime == ''||this.leaveTime==null){
                layerMsg('毕业时间不为空');
                return
            }
            if(this.major == ''||this.major==null){
                layerMsg('专业不为空');
                return
            }

            var that = this;
            $.ajax({
                url:that.services+"/user/resume/experienceEducation"
                ,type:"post"
                ,contentType:"application/json;charset=utf-8"
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,data:JSON.stringify({
                    "id": that.teachId
                    ,"resumeId": that.resumeId
                    ,"school":that.school
                    ,"educationLevel":that.currEducationId
                    ,"profession":that.major
                    ,"admissionTime":that.enterTime
                    ,"graduationTime":that.leaveTime
                })
                ,success:function(res){
                    if(res.success){
                        var check = ApiLoginStatus(res);
                        if(check==false)
                            return false;
                        layerMsg(res.message);
                        setTimeout(function() {
                            history.go(0);
                            layer.closeAll();
                        },500);
                    }
                }
            });
        }
    }
});

//项目经验
new Vue({
    el: "#pop_project_exper",
    data() {
        return {
            services: services,
            currIndex:'',
            currId:'',
            currResumeId:'',
            currProName:'',
            currProDuty:'',
            currWorkContext:'',
        }
    },
    created () {
        this.currResumeId = resume.resumeId;
        this.getinfo();
    },
    methods:{
        getinfo:function () {
            var that = this;
            $(document).on('click', '.edit-pro', function() {
                var index =  $(this).data('index');
                that.currId =  $(this).data('id');
                if(index!=undefined){
                    that.currIndex = index;
                    that.currProName=resume.experienceProject[that.currIndex].projectName;
                    that.currProDuty=resume.experienceProject[that.currIndex].duties;
                    that.currWorkContext=resume.experienceProject[that.currIndex].workContext;
                }
            })
        },
        alterPro:function () {
            if(this.currProName==''||this.currProName==null){
                layerMsg("项目名字不可以为空");
                return
            }
            var that = this;
            $.ajax({
                url:that.services+"/user/resume/experienceProject"
                ,type:"post"
                ,contentType:"application/json;charset=utf-8"
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,data:JSON.stringify({
                    "id": that.currId
                    ,"resumeId": that.currResumeId
                    ,"projectName": that.currProName
                    ,"duties": that.currProDuty
                    ,"workContext": that.currWorkContext
                })
                ,success:function(res){
                   if(res.success){
                       var check = ApiLoginStatus(res);
                       if(check==false)
                           return false;
                       layerMsg(res.message);
                       setTimeout(function() {
                           history.go(0);
                           layer.closeAll();
                       },500);
                   }

                }
            });
        },
        deletePro:function () {
            var that = this;
            $.ajax({
                url:that.services+"/user/resume/experienceProject/"+that.currId
                ,type:"delete"
                ,contentType:"application/json;charset=utf-8"
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,success:function(res){
                    if(res.success){
                        var check = ApiLoginStatus(res);
                        if(check==false)
                            return false;
                        layerMsg(res.message);
                        setTimeout(function() {
                            history.go(0);
                            layer.closeAll();
                        },500);
                    }

                }
            });
        }
    }
});
//添加项目经验
new Vue({
    el: "#add_pop_project_exper",
    data() {
        return {
            services: services,
            addProName:'',
            addProDuty:'',
            addProContext:'',
            ResumeId:''
        }
    },
    methods:{
        addPro:function () {
            if (this.addProName == '' || this.addProName == null) {
                layerMsg('项目名称不为空');
                return
            }
            var that = this;
            $.ajax({
                url: that.services + "/user/resume/experienceProject"
                , type: "put"
                , contentType: "application/json;charset=utf-8"
                , xhrFields: {
                    withCredentials: true
                }
                , crossDomain: true
                , data: JSON.stringify({
                    "resumeId": that.ResumeId,
                    "projectName": that.addProName,
                    "duties": that.addProDuty,
                    "workContext": that.addProContext
                })
                , success: function (res) {
                    if(res.success){
                        var check = ApiLoginStatus(res);
                        if(check==false)
                            return false;
                        layerMsg(res.message);
                        setTimeout(function () {
                            history.go(0);
                            layer.closeAll();
                        }, 500);
                    }
                }
            })
        }
    },
    created () {
        this.ResumeId = resume.resumeId;
    }
});

//个人介绍
new Vue({
    el: "#pop_intro",
    data() {
        return {
            services: services,
            intro:'',
            resumeId:''
        }
    },
    created () {
        this.intro = resume.resume.profile;
        this.resumeId = resume.resumeId;
    },
    methods:{
        alterIntro:function () {
            var that = this;
            $.ajax({
                url:that.services+"/user/resume"
                ,type:"post"
                ,contentType:"application/json;charset=utf-8"
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,data:JSON.stringify({
                    "id": that.resumeId,
                    "profile": that.intro,
                })
                ,success:function(res){
                    if(res.success){
                        var check = ApiLoginStatus(res);
                        if(check==false)
                            return false;
                        layerMsg(res.message);
                        setTimeout(function() {
                            history.go(0);
                            layer.closeAll();
                        },500);
                    }
                }
            });
        }
    }
});

//专业技能
var skill = new Vue({
    el: "#pop_skill",
    data() {
        return {
            services: services,
            proficiency:'',
            skillList:[],
            resumeId:'',
        }
    },
    created () {
        this.proficiency = this.init("get","/user/prop/skillProficiency/list?page=0&limit=10&name=");
        this.skillList = resume.professionalSkill;
        if(!this.skillList){
            this.skillList=[];
        }
        this.resumeId = resume.resumeId;
        this.deleteSkill();
    },
    methods:{
        init:function (_type,_url) {
            var that=this;
            var obj = "";
            $.ajax({
                type: _type,
                async:false,
                url: that.services+_url,
                xhrFields: {
                    withCredentials: true
                },
                crossDomain: true,
                success: function (res) {
                    var check = ApiLoginStatus(res);
                    if(check==false)
                        return false;
                    obj = (JSON.parse(res)).data;
                }
            });
            return obj;
        },
        addSkill:function() {
            var that = this;
            var obj = {
                skillName:'',
                proficiency:'',
                proficiencyName:'',
                id:'',
                name:'',
                resumeId:that.resumeId
            };
            if(that.skillList==null){
                that.skillList = [];
            }

            that.skillList.push(obj);
            setTimeout(function() {
               useLayUI();
            },30);
        },
        saveSkill:function () {
            for (var i=0;i<this.skillList.length;i++){
                var skillName = this.skillList[i].skillName;
                var profic = this.skillList[i].proficiency;
                if(skillName==''||skillName==null){
                   layerMsg('技能名称不为空');
                   return
                }
                if(profic==''||profic==null){
                    layerMsg('请选择熟悉程度');
                    return
                }
            }
            var that = this;
            $.ajax({
                url: that.services + "/user/resume/professionalSkill/save"
                , type: "post"
                , contentType: "application/json;charset=utf-8"
                , xhrFields: {
                    withCredentials: true
                }
                , crossDomain: true
                , data: JSON.stringify({
                    "professionalSkill": that.skillList,
                })
                , success: function (res) {
                    if(res.success){
                        var check = ApiLoginStatus(res);
                        if(check==false)
                            return false;
                        layerMsg(res.message);
                        setTimeout(function () {
                            history.go(0);
                            layer.closeAll();
                        }, 500);
                    }
                }
            })
        },
        deleteSkill:function () {
            var that = this;
            $(document).on('click', '.delete-skill', function() {
                var id =  $(this).data('id');
                var index =  $(this).data('index');
                // console.log(index)
                if(id==''||id==null){
                    // layerMsg('该技能信息尚未保存');
                    that.skillList.splice(index,1); 
                    // console.log(that.skillList)
                    return
                }
                $.ajax({
                    url: that.services + "/user/resume/professionalSkill/"+id
                    , type: "delete"
                    , contentType: "application/json;charset=utf-8"
                    , xhrFields: {
                        withCredentials: true
                    }
                    , crossDomain: true
                    , success: function (res) {
                        if(res.success){
                            var check = ApiLoginStatus(res);
                            if(check==false)
                                return false;
                            layerMsg(res.message);
                            setTimeout(function () {
                                history.go(0);
                                layer.closeAll();
                            }, 500);
                        }
                    }
                })
            })
        }
    }
});

layui.use(['form','upload'], function () {
    form = layui.form;
    form.on('select(profic-list)', function (data) {
        var id = data.elem.getAttribute("data");
        skill.skillList[id].proficiency=data.value;
    });
    //普通图片上传
    upload = layui.upload;
    upload.render({
        elem: '#imageUrlUpload'
        , url: services+"/user/upload/img"
        , before: function (obj) {
            //预读本地文件示例，不支持ie8

        }
        , done: function (res) {
            if(res.code==0){
                var fullPath = services + res.data.src;
                $('#imageUrlUpload').attr('src',fullPath);
                $('#img').val(res.data.src) ;
                console.log(res)
                layer.msg(res.msg);
            }
        }
        , error: function () {
            layer.msg("上传失败");
        }
    });
});



